<%@ Page Language="VB" MasterPageFile="~/site.master" AutoEventWireup="false" codefile="FanClubMatchReport.aspx.vb" Inherits="FanClubMatchReport" %>
<%@ Register TagPrefix="wu" TagName="FixtureList" Src="../FixtureList.ascx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="server">
    
    <wu:FixtureList ID="FixtureList1" Runat="server" />
    
    <br />

    <asp:sqldatasource id="SqlDataSource1" runat="server"
        selectcommand="SELECT [ReportID], [FixtureID], [Report], [MemberName] FROM [MatchReports] WHERE ([FixtureID] = @FixtureID) AND MemberName=@MemberName"
        DeleteCommand="DELETE FROM [MatchReports] WHERE [ReportID] = @ReportID"
        InsertCommand="INSERT INTO [MatchReports] ([FixtureID], [Report], [MemberName]) VALUES (@FixtureID, @Report, @MemberName)"
        UpdateCommand="UPDATE [MatchReports] SET [Report] = @Report WHERE [ReportID] = @ReportID"
        connectionstring="<%$ ConnectionStrings:WroxUnited %>"
        OnInserted="SqlDataSource1_Inserted"
        OnUpdated="SqlDataSource1_Updated">
        <DeleteParameters>
            <asp:Parameter Type="Int32" Name="ReportID"></asp:Parameter>
        </DeleteParameters>
        <UpdateParameters>
            <asp:ControlParameter Name="FixtureID" Type="Int32" ControlID="FixtureList1" PropertyName="SelectedValue"></asp:ControlParameter>
            <asp:Parameter Type="String" Name="Report"></asp:Parameter>
            <asp:Parameter Type="Int32" Name="ReportID"></asp:Parameter>
            <asp:ProfileParameter Type="string" Name="MemberName" PropertyName="MemberName"></asp:ProfileParameter>
        </UpdateParameters>
        <SelectParameters>
            <asp:ProfileParameter Type="string" Name="MemberName" PropertyName="UserName"></asp:ProfileParameter>
            <asp:ControlParameter Name="FixtureID" Type="Int32" ControlID="FixtureList1" PropertyName="SelectedValue"></asp:ControlParameter>
        </SelectParameters>
        <InsertParameters>
            <asp:ControlParameter Name="FixtureID" Type="Int32" ControlID="FixtureList1" PropertyName="SelectedValue"></asp:ControlParameter>
            <asp:Parameter Type="String" Name="Report"></asp:Parameter>
            <asp:ProfileParameter Type="string" Name="MemberName" PropertyName="UserName"></asp:ProfileParameter>
        </InsertParameters>
    </asp:sqldatasource>

    <asp:formview id="FormView1" runat="server" datasourceid="SqlDataSource1"
        datakeynames="ReportID" AllowPaging="true">
        <PagerSettings Mode="NextPreviousFirstLast"
            FirstPageImageUrl="~/Images/arrow_first.gif" FirstPageText="First report"
            LastPageImageUrl="~/Images/arrow_last.gif"  LastPageText="Last report"
            NextPageImageUrl="~/Images/arrow_next.gif" NextPageText="Next report"
            PreviousPageImageUrl="~/Images/arrow_prev.gif" PreviousPageText="Previous report" />
        <EmptyDataTemplate>
            <asp:LinkButton ID="AddReport" runat="server" Text="Add Report" OnClick="AddReport_Click" />
        </EmptyDataTemplate>
        <FooterTemplate>
        </FooterTemplate>
        <EditItemTemplate>
            <asp:TextBox id="TextBox1" runat="server" Text='<%# Bind("Report") %>' Rows="10" Columns="75" TextMode="MultiLine"></asp:TextBox> 
            <br />
            <asp:RequiredFieldValidator ID="rfv1" runat="server"
                ControlToValidate="TextBox1"
                Text="You haven't entered the report!" />
            <br />
            <asp:linkbutton id="btnUpdateReport" runat="server" CommandName="Update" Text="Save Changes" />
            <asp:linkbutton id="btnCancelReport" runat="server" CommandName="Cancel" Text="Cancel Changes" CausesValidation="false" />
            <p />
        </EditItemTemplate>
        <InsertItemTemplate>
            <asp:TextBox id="TextBox1" runat="server" Text='<%# Bind("Report") %>' Rows="10" Columns="75" TextMode="MultiLine"></asp:TextBox> 
            <br />
            <asp:RequiredFieldValidator ID="rfv1" runat="server"
                ControlToValidate="TextBox1"
                Text="You haven't entered the report!" />
            <br />
            <asp:linkbutton id="btnNewReport1" runat="server" CommandName="Insert" Text="Save New Report" />
            <asp:linkbutton id="btnCancelReport" runat="server" CommandName="Cancel" Text="Cancel New Report" CausesValidation="false" />
        </InsertItemTemplate>
        <ItemTemplate>
            <asp:Label Text='<%# Bind("Report") %>' runat="server" id="ReportLabel" /><br />
            <asp:linkbutton id="btnEditReport" runat="server" CommandName="Edit" Text="Edit Report" />
            <asp:linkbutton id="btnNewReport" runat="server" CommandName="New" Text="Add New Report" />
        </ItemTemplate>   
    </asp:formview>
  
</asp:Content>
